<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="__PUBLIC__/echarts/echarts.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>

<body>
<div class="layui-fluid main">
    <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
        <div class="layui-form-item" style="float: left;">
            <form class="layui-form serch" action="/admin/trip/index.shtml" method="post">
                <div class="layui-form-item" style="float: left;">
                    <div class="layui-input-inline">
                        <input type="text" name="tripname" lay-verify="title" value="{if isset($wherelist['tripname'])}{$wherelist['tripname']}{/if}" autocomplete="off" placeholder="请输入定制名称" class="layui-input layui-btn-sm">
                    </div>
                    <button class="layui-btn layui-btn-danger layui-btn-sm" lay-submit="" lay-filter="serch">搜索</button>
                    <a href="{:url('admin/trip/addtrip',['use_type'=>2])}" class="layui-btn layui-btn-sm a_menu">
                        新建定制
                    </a>
                    <a href="{:url('admin/trip/combination',['use_type'=>2])}" class="layui-btn layui-btn-sm a_menu">
                        组合定制
                    </a>
                </div>
            </form>

        </div>
    </fieldset>
    <table class="layui-table" lay-even="" lay-skin="line">
        <colgroup>
            <col width="50">
            <col width="400">
            <col width="100">
            <col width="100">
            <col width="100">
            <col width="100">
            <col width="100">
            <col width="300">
        </colgroup>
        <thead>

        <tr>
            <th>ID</th>
            <th>定制名称</th>
            <th>天数</th>
            <th>人数</th>
            <th>城市（数量）</th>
            <th>定制师</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="trip" id="vo"}
        <tr>
            <td>{$vo.id}</td>
            <td><strong>{$vo.name}</strong></td>
            <td>{$vo.days}</td>
            <td>{$vo.people}</td>
            <td>{$vo.citys}</td>
            <td>{$vo.admin}</td>
            <td>{$vo.create_time}</td>
            <td class="operation-menu">
                <a href="{:url('admin/trip/customized',['id'=>$vo.id])}" class="layui-btn layui-btn-xs"  style="margin-right: 0;font-size:12px;">定制行程</a>
                <a href="{:url('admin/trip/addtrip',['id'=>$vo.id])}" class="layui-btn layui-btn-xs layui-btn-warm a_menu"  style="margin-right: 0;font-size:12px;">编辑</a>
                <a  codeid="{$vo.id}" class="layui-btn layui-btn-xs layui-btn-warm copy"  style="margin-right: 0;font-size:12px;">复制</a>
                <a class="layui-btn layui-btn-xs layui-btn-danger delete"  codeid="{$vo.id}" style="margin-right: 0;font-size:12px;">删除</a>
                <a class="layui-btn layui-btn-xs" target="_blank" href="{:url('admin/trip/preview',['id'=>$vo.id])}"   style="margin-right: 0;font-size:12px;">预览</a>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>


    <script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>


    <script type="text/javascript">

        $('.delete').click(function(){
            var id = $(this).attr('codeid');
            layer.confirm('确定要删除?', function(index) {
                $.ajax({
                    url:"{:url('admin/trip/deltrip')}",
                    data:{id:id},
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code == 1) {
                            setTimeout(function(){
                                location.reload();
                            },1500)
                        }
                    }
                })
            })
        })

        $('.copy').click(function(){
            var id = $(this).attr('codeid');
            layer.confirm('确定复制吗:', {
                btn: ['产品','定制','取消'],
                btn1: function() {
                    $.ajax({
                        url:"{:url('admin/trip/copytrip')}",
                        data:{id:id, use_type:1},
                        success:function(res) {
                            layer.msg(res.msg);
                            if(res.code == 1) {
                                setTimeout(function(){
                                    location.reload();
                                },1500)
                            }
                        }
                    })
                },
                btn2: function() {
                    $.ajax({
                        url:"{:url('admin/trip/copytrip')}",
                        data:{id:id, use_type:2},
                        success:function(res) {
                            layer.msg(res.msg);
                            if(res.code == 1) {
                                setTimeout(function(){
                                    location.reload();
                                },1500)
                            }
                        }
                    })
                },
                btn3: function() {
                    layer.closeAll();
                }
            });
            return false;
        });
    </script>
    <script type="text/javascript">
        layui.use('layer', function(){
            var layer = layui.layer;
            $('.a_menu').click(function(){
                var url = $(this).attr('href');
                var a = 0;
                $.ajax({
                    url:url
                    ,async:false
                    ,success:function(res){
                        if(res.code == 0) {
                            layer.msg(res.msg);
                            a = 1;
                        }
                    }
                })
                if(a === 0) {
                    layer.open({
                        type:2,
                        content:url,
                        area: ['65%', '95%'],
                        end:function(){
                            location.reload();
                        }
                    });
                }
                return false;
            })

            $('.preview').click(function(){
                var url = $(this).attr('href');
                layer.open({
                    type:2,
                    content:url,
                    area: ['550px', '400px']
                });
                return false;
            })
        });
    </script>

</div>
</body>
</html>
